<?php

GaAPI_Autoloader::instance()->load('GaAPI_Objects_Common_Object');

class GaAPI_Objects_Report_Job extends GaAPI_Objects_Common_Object {

    public $id;
    public $selectedReportType;
    public $name;
    public $aggregationTypes;
    public $adWordsType;
    public $keywordType;
    public $startDay;
    public $endDay;
    public $selectedColumns = array();

    public function addColumn($name) {
        if (!in_array($name, $this->selectedColumns)) {
            $this->selectedColumns[] = $name;
        }
    }

    public function  __toString() {
        $xml = '';
        $xml .= '';
        $xml .= '<selectedReportType>' . $this->selectedReportType . '</selectedReportType>';
        $xml .= '<name>' . $this->name . '</name>';
        $xml .= '<aggregationTypes>' . $this->aggregationTypes . '</aggregationTypes>';
        $xml .= '<adWordsType>' . $this->adWordsType . '</adWordsType>';
        $xml .= '<keywordType>' . $this->keywordType . '</keywordType>';
        $xml .= '<startDay>' . $this->startDay . '</startDay>';
        $xml .= '<endDay>' . $this->endDay . '</endDay>';
        if (is_array($this->selectedColumns)) {
            if (count($this->selectedColumns) < 1) {
                $this->selectedColumns = array('Campaign', 'AdGroup', 'Keyword', 'KeywordStatus', 'KeywordMinCPC', 'KeywordDestUrlDisplay', 'Impressions', 'Clicks', 'CTR', 'AveragePosition');
            }
            foreach ($this->selectedColumns as $column) {
                $xml .= '<selectedColumns>' . $column . '</selectedColumns>';
            }
        }
        return $xml;
    }

}